#!/bin/bash

if [ ! -f gpkg ]; then 
    wget http://mirrors.dev.shopex.cn/lnmpp/release/lnmpp-0.0.2.tar.bz2 
    tar xf lnmpp-0.0.2.tar.bz2
    cd lnmpp-0.0.2
fi

if [ ! -f envinit.lock ]; then

    bash bin/envinit
    
    #uninstall useless package
    rpm -qa|grep  httpd
    rpm -e httpd
    rpm -qa|grep mysql
    rpm -e mysql
    rpm -qa|grep php
    rpm -e php
    
    yum -y remove httpd
    yum -y remove php
    yum -y remove mysql-server mysql
    yum -y remove php-mysql
    
    yum -y install yum-fastestmirror
    yum -y remove httpd
    yum -y update
    
    #install base
    for packages in patch make gcc gcc-c++ gcc-g77 flex bison file libtool libtool-libs autoconf kernel-devel libjpeg libjpeg-devel libpng libpng-devel libpng10 libpng10-devel gd gd-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glib2 glib2-devel bzip2 bzip2-devel libevent libevent-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel vim-minimal nano fonts-chinese gettext gettext-devel ncurses-devel gmp-devel pspell-devel unzip;
    do yum -y install $packages; done
    
    touch envinit.lock
fi
